package com.kevin.aqmp.consumer;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * SpringBoot 消费者测试类
 *
 * @author Kevin Liu
 * @date 2020/8/9 上午11:19
 */
@Component
public class SimpleQueueListener {

    @RabbitListener(queues = "first_test_queue")
    public void firstListener(String val, Channel channel, Message message) throws Exception {
        Thread.sleep(2000);
        System.out.println("1" + val);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

    @RabbitListener(queues = "first_test_queue")
    public void secondListener(String val, Channel channel, Message message) throws Exception{
        System.out.println("2"+val);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
